import {
  Controller,
  Get,
  Post,
  Body,
  Patch,
  Param,
  Delete,
  Put,
  UseInterceptors,
  UploadedFile
} from '@nestjs/common'
import * as xlsx from 'xlsx'
import { FileInterceptor } from '@nestjs/platform-express/multer'
import { ApiBody, ApiOperation, ApiParam, ApiTags } from '@nestjs/swagger'
import { NoAuth } from 'src/role/decorators/no-auth.decorator'
import { CalendarService } from './calendar.service'
import { CreateCalendarDto } from './dto/create-calendar.dto'
import { UpdateCalendarDto } from './dto/update-calendar.dto'
import { FResponse } from 'src/utils/reponse'
@NoAuth()
@ApiTags('日历信息')
@Controller('calendar')
export class CalendarController {
  constructor(private readonly calendarService: CalendarService) {}

  @Post()
  @ApiOperation({ summary: '创建日历信息' })
  @ApiBody({ type: CreateCalendarDto, description: '日历信息信息' })
  async create(@Body() createCalendarDto: CreateCalendarDto) {
    return FResponse.success(
      await this.calendarService.create(createCalendarDto)
    )
  }

  @Post('all/:id')
  @ApiOperation({ summary: '获取所有日历信息' })
  @ApiBody({
    description: '日历信息信息'
  })
  async findAll(@Param('id') id: string) {
    return FResponse.success(await this.calendarService.findAll(+id))
  }

  @Patch(':id')
  @ApiOperation({ summary: '修改指定日历信息' })
  @ApiParam({ name: 'id', description: '日历信息ID' })
  @ApiBody({ type: UpdateCalendarDto, description: '日历信息信息' })
  async update(
    @Param('id') id: string,
    @Body() updateCalendarDto: UpdateCalendarDto
  ) {
    return FResponse.success(
      await this.calendarService.update(+id, updateCalendarDto)
    )
  }

  // 彻底删除
  @Delete('thorough')
  @ApiOperation({ summary: '批量彻底删除日历信息' })
  @ApiBody({ type: [Number], description: '日历信息ID数组' })
  async batchThoroughRemove(@Body() ids: number[]) {
    return FResponse.success(await this.calendarService.thoroughRemove(ids))
  }

  // 批量删除
  @Delete()
  @ApiOperation({ summary: '批量删除日历信息' })
  @ApiBody({ type: [Number], description: '日历信息ID数组' })
  async batchRemove(@Body() ids: number[]) {
    return FResponse.success(await this.calendarService.remove(ids))
  }
}
